package src.mcpichess.pieces;

import java.util.ArrayList;

import src.mcpichess.control.Main;


public class King extends Piece{
	
	public King(Main m){
		byte[][][] s = {
				{{1,0,1},{0,0,0},{1,0,1}},
				{{1,1,1},{1,1,1},{1,1,1}},
				{{0,0,0},{0,1,0},{0,0,0}},		//King
				{{0,0,0},{0,1,0},{0,0,0}},
				{{1,1,1},{1,1,1},{1,1,1}},
			};
		structure = s;
		main = m;
	}
	
	@Override
	public ArrayList<int[]> getMoves(int x, int z, int player) {
		ArrayList<int[]> rList = new ArrayList<int[]>();
		
		int[][] points = {
				{-1,-1},
				{-1,0},
				{-1,1},
				{0,-1},
				{0,1},
				{1,-1},
				{1,0},
				{1,1}
		};
		for (int[] i : points){
			int newX = x-i[0];
			int newZ = z-i[1];
			if (newX >= 0 && newX <=7 && newZ >=0 && newZ <=7){
				if (main.getPlayerAt(Main.pair(newX, newZ)) != player){
					int[] ia = {newX, newZ};
					rList.add(ia);
				}
			}
		}
		
		return rList;
		
	}

	@Override
	public int getBlockAt(int x, int y, int z) {
		return structure[y][z][x];
	}
	
	@Override
	public int getNum() {
		return 6;
	}
	
}
